/*
 * @Descripttion:
 * @version:
 * @Author: kl2018
 * @Date: 2020-03-17 09:11:31
 * @LastEditors: kl2018
 * @LastEditTime: 2020-06-22 18:56:31
 */
import React from 'react';
import loadjs from 'loadjs';
import { WeaTools } from 'ecCom';

export default class BatchSubmit extends React.Component {
	constructor() {
		super();
		this.state = { hasLoad: false };
	}
	componentDidMount() {
		const init = () => {
			this.setState({ hasLoad: true });
		};
		const staticVersion = `?v${WeaTools && WeaTools.ls && WeaTools.ls.getStr('staticVersion') || 0}`;

		const workflowPublicFiles = [
			`/spa/workflow/static4public/index.js${staticVersion}`,
			'/spa/workflow/static4public/index.css',
		];
		loadjs.isDefined('workflowPublic') ? loadjs.ready('workflowPublic', init) : loadjs(workflowPublicFiles, 'workflowPublic', init);
	}
	render() {
		const { hasLoad } = this.state;
		if (hasLoad) {
			const { WfBatchSubmit } = window.weaWorkflowPublic;
			const { onSubmit, visible, onCancel, onSubmitText = '', iconClassName = '' } = this.props;
			return (<WfBatchSubmit ecId={`${this && this.props && this.props.ecId || ''}_WfBatchSubmit@gn68k6`} onSubmit={onSubmit} onCancel={onCancel} visible={visible} onSubmitText={onSubmitText} iconClassName={iconClassName} />);
		}
			return (<div />);
	}
}
